<template>
  <div>
    <input placeholder="输入关键字搜索" @keyup.enter="search" v-model="txt" />
    <BiaoGe :list="records1"></BiaoGe>
  </div>
</template>
<script>
import BiaoGe from "./components/BiaoGe.vue";
export default {
  data() {
    return {
      records: [
        {
          date: "2022-01-01",
          doctor: "张三",
          diagnosis: "感冒",
          prescription: "感冒药",
        },
        {
          date: "2022-02-01",
          doctor: "李四",
          diagnosis: "头疼",
          prescription: "止疼药",
        },
        {
          date: "2022-03-01",
          doctor: "王五",
          diagnosis: "腰痛",
          prescription: "止痛贴",
        },
      ],
      records1: [],
      txt: "",
    };
  },
  components: {
    BiaoGe,
  },
  methods: {
    search() {
      this.records1 = [];
      for (let i = 0; i < this.records.length; i++) {
        if (this.records[i].doctor === this.txt) {
          this.records1.push(this.records[i]);
        }
      }
    },
  },
};
</script>
<style lang="less" scoped></style>
